Skip to content

Make detailed find agree with info on duplicate Drive paths - #422

Merged
shcheklein merged 2 commits into
mainfrom
fs/find-duplicate-paths
Nov 30, 2026
Merged

shcheklein merged 2 commits into
mainfrom
fs/find-duplicate-paths

Conversation

@shcheklein

Copy link
Copy Markdown
Member

Fixes #421.

If two Drive items share a path, find(withdirs=True, detail=True) now reports the item with the lowest Drive ID, just as info() does. All matching folders still contribute descendants, including when a file supplies the metadata for their shared path. Files-only detailed searches choose the lowest eligible file ID.

The walk compares siblings from all physical folders at each logical path. It sorts temporary references for that directory and records an ID preference only for repeated names. Individual file IDs do not enter the filesystem cache.

Verification

Public filesystem tests cover cold and warm duplicate ancestors, both outcomes of a file/folder collision, a collision at the starting path, and three same-name files split across response pages. The warm reproduction uses one Drive listing. The cold reproduction uses four.

The offline suite passed (333 passed, 2 skipped). Ruff, mypy and the Sphinx build with warnings treated as errors passed.

Simulated listing performance

Cold find("root", withdirs=True, detail=True) over 262,144 files on Python 3.12 with a paginated in-process Drive transport. Each figure is the median of three fresh processes per revision, compared with 0104333.

Layout Drive calls (main / PR) Peak RSS (main / PR) CPU seconds (main / PR)
256 folders × 1,024 files 268 / 268 208.7 / 211.0 MiB 1.13 / 1.18
One folder × 262,144 files 263 / 263 185.7 / 191.0 MiB 1.09 / 1.20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes aligning duplicate-path listing metadata with info().

No open issues 🎉

What changed in this PR

This PR addresses #421 by making detailed Drive filesystem listings select duplicate-path metadata consistently with info(), while preserving traversal through every matching folder.

Changes:

  • Selects the lowest eligible Drive ID for duplicate paths, including file/folder collisions when directories are requested.
  • Groups children by logical parent path and tracks ID preferences only for repeated names.
  • Adds regression tests for cold and warm caches, pagination, and starting-path collisions, and documents the behavior.
File Description
pydrive2/​test/​test_fs_unit.py Adds duplicate-path selection and traversal regression tests.
pydrive2/​fs/​spec.py Implements deterministic metadata selection across duplicate paths.
docs/​fsspec.rst Documents ID selection and traversal of matching folders.

Review effort: Balanced

@shcheklein shcheklein left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — no blocking issues found. Per-path grouping in _walk_folders, duplicate-only tie-breaking in _preferred_ids, and folders_only=not (withdirs and detail) integrate cleanly with DirectoryCache while keeping memory overhead minimal. Left a few minor non-blocking notes inline.

Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/test/test_fs_unit.py Resolved
@shcheklein
shcheklein merged commit 9c417a2 into main Nov 30, 2026
37 of 39 checks passed
@shcheklein
shcheklein deleted the fs/find-duplicate-paths branch November 30, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make detailed find and info agree on duplicate Drive paths

2 participants